<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <link rel="apple-touch-icon" sizes="76x76" href="{_INDEX_STATIC_}/moban/assets/img/apple-icon.png">
    <link rel="icon" type="image/png" href="{_INDEX_STATIC_}/moban/assets/img/favicon.png">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>成果审核 | {$system_name}</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
        name='viewport' />
    <link href="{_INDEX_STATIC_}/moban/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="{_INDEX_STATIC_}/moban/assets/css/now-ui-kit.css?v=1.1.0" rel="stylesheet" />
    <link href="{_INDEX_STATIC_}/moban/assets/css/font-awesome.min.css" rel="stylesheet" />
</head>

<body class="index-page sidebar-collapse">

    <!-- 引入导航栏 -->
    {include file='public/header'}

    <div class="container" style="min-height: 490px;">
        <div class="row">
            <div class="col-md-12">
                <h3>成果审核 - 审核详情</h3>
            </div>
            <button class="btn btn-danger" onclick="back()">返回上一页</button>
            <button class="btn btn-danger bg-success" onclick="get_all()">查看全部</button>
            <button class="btn btn-danger bg-info" onclick="get_status(1)">查看已提交</button>
            <button class="btn btn-danger bg-info" onclick="get_status(4)">查看已通过</button>
            <button class="btn btn-danger bg-info" onclick="get_status(3)">查看已驳回</button>
        </div>

        {volist name="classify_table_other_data" id="ctod_row" key="i"}
        <div class="row" style="border: 1px solid #ddd;padding:30px;">
            <div class="col-md-12" style="font-size: 18px;">{$i}.</div>            
            {volist name="classify_table_info.table_content.names" id="row" key="j"}
            <div class="col-md-4">
                <div class="input-group">
                    <span class="input-group-addon">
                        &nbsp;{$row}
                    </span>
                    {if
                    condition="$classify_type_list[$classify_table_info.table_content.selects[$j-1]-1]['name'] ==
                    '时间'"}
                    <div class="form-control">
                        {$classify_table_other_data[$i-1][$classify_table_info.table_content.cols[$j-1]] |
                        date='Y-m-d'}
                    </div>
                    {else /}
                    {if
                    condition="$classify_type_list[$classify_table_info.table_content.selects[$j-1]-1]['name'] ==
                    '数值'"}
                    <div class="form-control">
                        {$classify_table_other_data[$i-1][$classify_table_info.table_content.cols[$j-1]] / 100 |
                        floatval}
                    </div>
                    {else /}
                    <div class="form-control">
                        {$classify_table_other_data[$i-1][$classify_table_info.table_content.cols[$j-1]]}
                    </div>
                    {/if}
                    {/if}
                </div>
            </div>
            {/volist}
            <!-- 按钮 -->
            <div class="col-md-12 text-center">
                <div class="dropup">
                    <button id="btn_{$classify_table_other_data[$i-1]['id']}" type="button"
                        class="btn btn-info dropup-toggle" data-toggle="dropdown">
                        修改状态 - {$classify_table_other_data[$i-1]['status'] | achievement_submit_status}
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item text-info" style="cursor: pointer;"
                            onclick="set_status('{$classify_table_other_data[$i-1]['pid']}','{$classify_table_other_data[$i-1]['id']}',1)">已提交</a>
                        <a class="dropdown-item text-success" style="cursor: pointer;"
                            onclick="set_status('{$classify_table_other_data[$i-1]['pid']}','{$classify_table_other_data[$i-1]['id']}',4)">已通过</a>
                        <a class="dropdown-item text-default" style="cursor: pointer;"
                            onclick="set_status('{$classify_table_other_data[$i-1]['pid']}','{$classify_table_other_data[$i-1]['id']}',3)">已驳回</a>
                    </div>
                </div>
            </div>
        </div>
        {/volist}

    </div>

    <!-- 引入页脚 -->
    {include file='public/footer'}

    <script>
        // 返回 
        function back() {
            redirect_url("{:url('achievement_audit/details')}?cid={$cid}")
        }

        // 查看全部
        function get_all(){
            redirect_url("{:url('achievement_audit/audit_details')}?cid={$cid}&uid={$uid}")
        }

        // 获取其他的状态
        function get_status(status){
            redirect_url("{:url('achievement_audit/audit_details')}?cid={$cid}&uid={$uid}&status=" + status)
        }

        // 设置状态
        function set_status(pid, id, status) {
            layer.confirm('是否调整为该状态？', {
                btn: ['是', '否'] //按钮
            }, function () {
                var status_str = '';
                var note = '';

                if (status == 3) {
                    status_str = '已驳回';
                    layer.prompt({ title: '请填写要驳回的理由', formType: 2 }, function (note, index) {
                        layer.close(index);
                        note = note;

                        $.ajax({
                        url: "{:url('achievement_audit/set_status')}",
                        data: {
                            'pid': pid,
                            'id': id,
                            'status': status,
                            'note': note
                        },
                        type: "POST",
                        dataType: "JSON",
                        async: true,
                        success: function (res) {
                            // 返回结果处理
                            if (res.code == 0) {
                                return layer.msg(res.msg, { icon: 1, time: 900 }, function () {
                                    $('#btn_' + id).html("修改状态 - " + status_str);
                                });
                            } else {
                                return layer.msg(res.msg, { icon: 2, time: 900 });
                            }
                        }
                    });
                    });
                } else {
                    if (status == 4) {
                        status_str = '已通过';
                    } else if (status == 1) {
                        status_str = '已提交';
                    }

                    $.ajax({
                        url: "{:url('achievement_audit/set_status')}",
                        data: {
                            'pid': pid,
                            'id': id,
                            'status': status,
                            'note': note
                        },
                        type: "POST",
                        dataType: "JSON",
                        async: true,
                        success: function (res) {
                            // 返回结果处理
                            if (res.code == 0) {
                                return layer.msg(res.msg, { icon: 1, time: 900 }, function () {
                                    $('#btn_' + id).html("修改状态 - " + status_str);
                                });
                            } else {
                                return layer.msg(res.msg, { icon: 2, time: 900 });
                            }
                        }
                    });
                }

            }, function () { });
        }

        // 重定向
        function redirect_url(url) {
            window.location.href = url;
        }
    </script>
</body>

</html>